<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<link rel="stylesheet" href="<c:url value='/css/chosen.css'/>" />
<script src="<c:url value='/js/chosen.jquery.js'/>"></script>
<script type="text/javascript">
	function valid() {
		$("#help_name").val("英文");
		$("#div_name").removeClass("control-group error");
		$("#div_name").addClass("control-group");
		$("#div_type").removeClass("control-group error");
		$("#div_type").addClass("control-group");
		var name = $("#name").val().trim();
		if (name == "") {
			$("#div_name").removeClass("control-group");
			$("#div_name").addClass("control-group error");
			document.getElementById("help_name").innerHTML = "航电设备名称不能为空";
			return false;
		}
		var type = $("#equiptype").val().trim();
		if (type == "") {
			$("#div_type").removeClass("control-group");
			$("#div_type").addClass("control-group error");
			document.getElementById("help_type").innerHTML = "请选择航电设备类别";
			return false;
		}
		return true;
	}
	$(function() {
		$('.chosen-select').chosen({
			/*max_selected_options: 2,*/
			no_results_text : "没有找到",
			allow_single_deselect : true
		});
	});
	function goback() {
		history.go(-1);
	}
</script>

<div class="page-header">
	<h3 style="margin-top: auto">新增航电设备</h3>
</div>
<div class="row-fluid">
	<div>
		<form class="form-horizontal"
			action="<%=request.getContextPath()%>/domain_entity/equipment/add"
			method="POST" onsubmit="return valid()">
			<div class="control-group" id="div_name">
				<label class="control-label">名称</label>
				<div class="controls">
					<input type="text" placeholder="名称" id="name" name="name">
					<span class="help-inline" id="help_name">英文</span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">中文名称</label>
				<div class="controls">
					<input type="text" placeholder="中文名称" id="cnName" name="cnName">
				</div>
			</div>
			<div class="control-group" id="div_type">
				<label class="control-label">设备类别</label>
				<div class="controls">
					<div class="form-inline">
						<select style="width: 200px" id="equiptype" name="equiptype"
							data-placeholder="选择设备类别" class="chosen-select" tabindex="1">
							<option value=""></option>
							<option value="总线">总线</option>
							<option value="外部设备">外部设备</option>
							<option value="内部设备">内部设备</option>
						</select><span class="help-inline" id="help_type"></span>
					</div>
				</div>
			</div>
			<c:choose>
				<c:when test="${!empty categoryList}">
					<div class="control-group">
						<label class="control-label">设备属性类别</label>
						<div class="controls">
							<div class="form-inline">
								<select style="width: 200px" id="equipment_type"
									name="equipment_type" data-placeholder="选择属性类别"
									class="chosen-select" tabindex="1">
									<c:forEach items="${categoryList}" var="item">
										<option value="${item.id}">
											<c:out value="${item.type}" />
										</option>
									</c:forEach>
								</select>
							</div>
						</div>
					</div>
				</c:when>
			</c:choose>
			<div class="control-group">
				<label class="control-label">描述信息</label>
				<div class="controls">
					<textarea rows="3" class="input-xxlarge" placeholder="描述信息"
						id="description" name="description"></textarea>
				</div>
			</div>
			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn" id="submit"><i class="icon-ok"></i>&nbsp;提交</button>
					<button type="button" class="btn" style="margin-left=50px;" onclick="goback()"><i class="icon-remove"></i>&nbsp;取消</button>
				</div>
			</div>
		</form>
	</div>
</div>
<!--/row-->